package com.it.stone_manage.controller;

import com.it.stone_manage.model.OptionSearch;
import com.it.stone_manage.model.SQLData;
import com.it.stone_manage.model.SearchData;
import com.it.stone_manage.model.TypeData;
import com.it.stone_manage.service.TypeService;
import com.it.stone_manage.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;
import java.util.Map;
import java.util.Set;

@RestController
//解决跨域问题
@CrossOrigin
public class TypeController {
    @Autowired
    TypeService typeService;

    @PostMapping("searchOptions")
    public Set<Map<String ,String> > searchOptions(@RequestBody OptionSearch optionSearch){
        return typeService.searchOptions(optionSearch);
    }
    @PostMapping("formOptions")
    public Set<Map<String ,String> > formOptions(@RequestBody SQLData sqlData){
        return typeService.formOptions(sqlData);
    }
    @PostMapping("searchTypeData")
    public List<TypeData> searchTypeData(@RequestBody SearchData searchData){
        return typeService.searchTypeData(searchData);
    }
    @PostMapping("beforeSave")
    public Result beforeSave(@RequestBody TypeData typeData){
       return typeService.beforeSave(typeData);
    }
    @PostMapping("saveTypeData")
    public Result saveTypeData(@RequestBody TypeData typeData){
        return typeService.saveTypeData(typeData);
    }
    @PostMapping("deleteTypeData")
    public Result deleteTypeData(@RequestBody TypeData typeData){
        return typeService.deleteTypeData(typeData);
    }
}
